<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">

    <ui:define name="content">
        <p:panel id="panel" header="View Customers">
            <h:form>
            <p:dataTable var="customer" value="#{viewCustomerList.customers}" 
                         dynamic="true" paginator="true" rows="5" emptyMessage="No customer found in database." selection="#{viewCustomerList.selectedCustomer}"> 

                        <p:column selectionMode="single" />

                        <p:column sortBy="#{customer.saleLeadName}" filterBy="#{customer.saleLeadName}"> 
                            <f:facet name="header"> 
                                <h:outputText value="Name" /> 
                            </f:facet> 
                            <h:outputText value="#{customer.saleLeadName}" /> 
                        </p:column>

                        <p:column sortBy="#{customer.registrationNumber}" filterBy="#{customer.registrationNumber}"> 
                            <f:facet name="header"> 
                                <h:outputText value="Registration Number" /> 
                            </f:facet> 
                            <h:outputText value="#{customer.registrationNumber}" /> 
                        </p:column> 

                        <p:column sortBy="#{customer.saleLeadAddress}" filterBy="#{customer.saleLeadAddress}"> 
                            <f:facet name="header"> 
                                <h:outputText value="Address" /> 
                            </f:facet> 
                            <h:outputText value="#{customer.saleLeadAddress}" /> 
                        </p:column>

                        <p:column sortBy="#{customer.customerType}" filterBy="#{customer.customerType}"> 
                            <f:facet name="header"> 
                                <h:outputText value="Customer Type" /> 
                            </f:facet> 
                            <h:outputText value="#{customer.customerType}" /> 
                        </p:column>

                        <f:facet name="footer">  
                            <p:commandButton value="Edit" image="ui-icon ui-icon-pencil" actionListener="#{viewCustomerList.editCustomer}"/>     
                            <p:commandButton value ="Delete" image="ui-icon ui-icon-trash" onclick="customerDeleteDialog.show()" />
                            <p:growl id="messages" />
                            <p:menuButton value="Other Options">
                                <p:menuitem value="View Sale Inquiries" update = "messages" actionListener="#{viewCustomerList.viewSaleInquiries(event)}" />
                                <p:menuitem value="View Sale Quotations" update = "messages" actionListener="#{viewCustomerList.viewSaleQuotations}" />
                                <p:menuitem value="View Sale Orders" update ="messages" actionListener="#{viewCustomerList.viewSaleOrders}" />
                            </p:menuButton>
                        </f:facet>
                     </p:dataTable>   

                <p:confirmDialog message="Are you sure to delete the customer?"  
            showEffect="clip" hideEffect="fold" 
            header="Initiating delete process" severity="alert" widgetVar="customerDeleteDialog">  

                    <p:commandButton value="Yes" update="messages" oncomplete= "customerDeleteDialog.hide()"  
                                actionListener="#{viewCustomerList.deleteCustomer}" />  
                    <p:commandButton value="No" onclick="customerDeleteDialog.hide()" type="button" />   

                </p:confirmDialog>  


            </h:form>
        </p:panel>
    </ui:define>

</ui:composition>
